Skip to content

Modernize C# code snippets - System/U*, System/V*, System/W* - #12974

Draft
gewarren wants to merge 9 commits into
dotnet:mainfrom
gewarren:modernize-code-system-uv
Draft

Modernize C# code snippets - System/U*, System/V*, System/W*#12974
gewarren wants to merge 9 commits into
dotnet:mainfrom
gewarren:modernize-code-system-uv

Conversation

@gewarren

@gewarren gewarren commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Contributes to #12713.


Internal previews

Toggle expand/collapse
File Preview link
snippets/csharp/System/UInt16/CompareTo/source.cs Preview published page
snippets/csharp/System/UInt16/Equals/equalsoverl.cs Preview published page
snippets/csharp/System/UInt16/Equals/uint16_equals.cs Preview published page
snippets/csharp/System/UInt16/MaxValue/MaxValue.cs Preview published page
snippets/csharp/System/UInt16/Parse/parseex2.cs Preview published page
snippets/csharp/System/UInt16/Parse/parseex3.cs Preview published page
snippets/csharp/System/UInt16/Parse/parseex4.cs Preview published page
snippets/csharp/System/UInt16/Parse/parseex5.cs Preview published page
snippets/csharp/System/UInt16/ToString/tostring1.cs Preview published page
snippets/csharp/System/UInt16/ToString/tostring2.cs Preview published page
snippets/csharp/System/UInt16/ToString/tostring3.cs Preview published page
snippets/csharp/System/UInt16/ToString/tostring4.cs Preview published page
snippets/csharp/System/UInt16/TryParse/tryparse11.cs Preview published page
snippets/csharp/System/UInt16/TryParse/tryparse2.cs Preview published page
snippets/csharp/System/UInt16/TryParse/tryparse21.cs Preview published page
snippets/csharp/System/UInt32/CompareTo/source.cs Preview published page
snippets/csharp/System/UInt32/Equals/equalsoverl.cs Preview published page
snippets/csharp/System/UInt32/Equals/uint32_equals.cs Preview published page
snippets/csharp/System/UInt32/MaxValue/MaxValue1.cs Preview published page
snippets/csharp/System/UInt32/Parse/parse1.cs Preview published page
snippets/csharp/System/UInt32/Parse/parseex2.cs Preview published page
snippets/csharp/System/UInt32/Parse/parseex4.cs Preview published page
snippets/csharp/System/UInt32/ToString/tostring1.cs Preview published page
snippets/csharp/System/UInt32/ToString/tostring2.cs Preview published page
snippets/csharp/System/UInt32/ToString/tostring3.cs Preview published page
snippets/csharp/System/UInt32/ToString/tostring4.cs Preview published page
snippets/csharp/System/UInt64/CompareTo/source.cs Preview published page
snippets/csharp/System/UInt64/Equals/equals1.cs Preview published page
snippets/csharp/System/UInt64/Equals/equalsoverl.cs Preview published page
snippets/csharp/System/UInt64/Equals/uint64_equals.cs Preview published page

Note

This table shows the first 30 preview links (sorted alphabetically by file path) found in the OPS build report. For the full list, select OpenPublishing.Build Details within checks.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes a large set of .NET API documentation C# snippets in the System/U*, System/V*, and System/W* areas, aligning them with newer C# idioms as part of issue #12713.

Changes:

  • Updated snippets to modern C# syntax (target-typed new, expression-bodied members, switch expressions, and string interpolation).
  • Removed unused using directives and normalized formatting/indentation.
  • Refreshed several snippet implementations to use updated patterns (for example, object initializers and simplified Console.WriteLine formatting).

Reviewed changes

Copilot reviewed 77 out of 78 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
snippets/csharp/System/WeakReference/Overview/program.cs Modern C# syntax and formatting in WeakReference cache example.
snippets/csharp/System/Version/TryParse/tryparse1.cs Modernized formatting and string interpolation in TryParse example.
snippets/csharp/System/Version/Parse/parse1.cs Modernized formatting and string interpolation in Parse example.
snippets/csharp/System/Version/Overview/GettingVersions1.cs Removed unused using and kept snippet minimal/clean.
snippets/csharp/System/Version/Overview/example1.cs Simplified attribute usage and modernized output formatting.
snippets/csharp/System/Version/Overview/currentassem.cs Modernized formatting and string interpolation.
snippets/csharp/System/Version/Overview/currentapp.cs Modernized formatting and string interpolation.
snippets/csharp/System/Version/Overview/comparisons2.cs Reformatted enum and simplified method body/output.
snippets/csharp/System/Version/Overview/comparisons1.cs Modernized control flow using switch expression.
snippets/csharp/System/Version/.ctor/rev.cs Target-typed new and formatting normalization.
snippets/csharp/System/ValueType/ToString/ToString2.cs Modernized types (string) and simplified overrides.
snippets/csharp/System/ValueType/Overview/example1.cs Modernized formatting and simplified helper methods.
snippets/csharp/System/ValueType/Equals/source.cs Reformatted code and simplified GetHashCode implementation.
snippets/csharp/System/UriBuilder/Query/main.cs Removed unused usings and modernized UriBuilder construction.
snippets/csharp/System/UriBuilder/Fragment/source.cs Modernized construction using object initializer; removed unused usings.
snippets/csharp/System/UriBuilder/.ctor/source3.cs Modernized formatting and UriBuilder construction.
snippets/csharp/System/UriBuilder/.ctor/source2.cs Modernized formatting and UriBuilder construction.
snippets/csharp/System/UriBuilder/.ctor/source1.cs Modernized formatting and UriBuilder construction.
snippets/csharp/System/UriBuilder/.ctor/source.cs Modernized formatting and UriBuilder construction.
snippets/csharp/System/Uri/Scheme/source.cs Removed unused usings and modernized Uri construction.
snippets/csharp/System/Uri/Port/source.cs Removed unused usings and modernized Uri construction.
snippets/csharp/System/Uri/PathAndQuery/source.cs Removed unused usings and modernized Uri construction/output.
snippets/csharp/System/Uri/Overview/source.cs Modernized Uri construction and expanded/normalized sample output formatting.
snippets/csharp/System/Uri/HostComparison/source.cs Modernized Uri constructions in host comparison examples.
snippets/csharp/System/Uri/Host/source.cs Removed unused usings and modernized Uri construction.
snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs Modernized many snippet sections (interpolation, target-typed new, formatting).
snippets/csharp/System/Uri/CheckHostName/source.cs Removed unused usings and modernized formatting/indentation.
snippets/csharp/System/Uri/Authority/source.cs Removed unused usings and modernized Uri construction/output.
snippets/csharp/System/Uri/AbsoluteUri/source.cs Removed unused usings and modernized Uri construction.
snippets/csharp/System/Uri/AbsolutePath/source.cs Removed unused usings and modernized Uri construction.
snippets/csharp/System/Uri/.ctor/source2.cs Removed unused usings and modernized formatting/indentation.
snippets/csharp/System/Uri/.ctor/source.cs Removed unused usings and modernized formatting/indentation.
snippets/csharp/System/Uri/.ctor/nclurienhancements.cs Modernized formatting and Uri constructions across snippets.
snippets/csharp/System/UnauthorizedAccessException/Overview/withio.cs Modernized formatting and simplified object creation syntax.
snippets/csharp/System/UIntPtr/Subtract/subtract1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UIntPtr/op_Addition/op_subtraction1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UIntPtr/op_Addition/op_addition1.cs Modernized formatting for operator-based pointer arithmetic example.
snippets/csharp/System/UIntPtr/Add/add1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt64/TryParse/tryparse2.cs Modernized formatting and updated to keyword aliases (ulong).
snippets/csharp/System/UInt64/TryParse/tryparse1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt64/ToString/tostring4.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt64/ToString/tostring3.cs Modernized formatting and removed unused using.
snippets/csharp/System/UInt64/ToString/tostring2.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt64/ToString/tostring1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt64/Parse/parseex4.cs Modernized formatting, parsing calls, and string interpolation output.
snippets/csharp/System/UInt64/Parse/parseex2.cs Modernized formatting and string interpolation output for parse attempts.
snippets/csharp/System/UInt64/Parse/parse1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt64/MaxValue/MaxValue1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt64/Equals/uint64_equals.cs Modernized formatting, keyword aliases, and output strings.
snippets/csharp/System/UInt64/Equals/equalsoverl.cs Modernized formatting and condensed helper output logic.
snippets/csharp/System/UInt64/Equals/equals1.cs Modernized formatting, keyword aliases, and output strings.
snippets/csharp/System/UInt64/CompareTo/source.cs Large formatting modernization and updated parsing/ToString patterns.
snippets/csharp/System/UInt32/ToString/tostring4.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt32/ToString/tostring3.cs Modernized formatting and removed unused using.
snippets/csharp/System/UInt32/ToString/tostring2.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt32/ToString/tostring1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt32/Parse/parseex4.cs Modernized formatting, parsing calls, and string interpolation output.
snippets/csharp/System/UInt32/Parse/parseex2.cs Modernized formatting and string interpolation output for parse attempts.
snippets/csharp/System/UInt32/Parse/parse1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt32/MaxValue/MaxValue1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt32/Equals/uint32_equals.cs Modernized formatting and exception output string interpolation.
snippets/csharp/System/UInt32/Equals/equalsoverl.cs Modernized formatting and condensed helper output logic.
snippets/csharp/System/UInt32/CompareTo/source.cs Large formatting modernization and updated parsing/ToString patterns.
snippets/csharp/System/UInt16/TryParse/tryparse21.cs Modernized formatting and updated to keyword aliases.
snippets/csharp/System/UInt16/TryParse/tryparse2.cs Modernized formatting and updated to keyword aliases.
snippets/csharp/System/UInt16/TryParse/tryparse11.cs Modernized formatting and updated to keyword aliases.
snippets/csharp/System/UInt16/ToString/tostring4.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt16/ToString/tostring3.cs Modernized formatting and removed unused using.
snippets/csharp/System/UInt16/ToString/tostring2.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt16/ToString/tostring1.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt16/Parse/parseex5.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt16/Parse/parseex4.cs Modernized formatting, parsing calls, and string interpolation output.
snippets/csharp/System/UInt16/Parse/parseex3.cs Modernized formatting and string interpolation output.
snippets/csharp/System/UInt16/Parse/parseex2.cs Modernized formatting and string interpolation output for parse attempts.
snippets/csharp/System/UInt16/MaxValue/MaxValue.cs Modernized formatting; retained range-check pattern.
snippets/csharp/System/UInt16/Equals/uint16_equals.cs Updated type aliases and modernized exception output formatting.
snippets/csharp/System/UInt16/Equals/equalsoverl.cs Modernized formatting and condensed helper output logic.
snippets/csharp/System/UInt16/CompareTo/source.cs Large formatting modernization and updated parsing/ToString patterns.
Suppressed comments (1)

snippets/csharp/System/Version/Parse/parse1.cs:63

  • The documented sample output has the same missing closing apostrophe as the code. After fixing the message format, update the output comment lines so they match the actual output.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread snippets/csharp/System/Version/TryParse/tryparse1.cs
Comment thread snippets/csharp/System/Version/Parse/parse1.cs
Comment thread snippets/csharp/System/UInt16/MaxValue/MaxValue.cs Outdated
Comment thread snippets/csharp/System/Uri/Overview/source.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants